﻿using System.Collections;
using System.Collections.Generic;
using Assets.Scripts.NetFrame;
using Assets.Scripts.UserCache;
using UnityEngine;
using UnityEngine.UI;
using WorldOfSuperpowers_COMMON;
using WorldOfSuperpowers_COMMON.DataModel;

public class RenameManager : MonoBehaviour
{

    public static RenameManager _instance;

    public GameObject RenamePanel;
    public InputField NameInput;

    void  Awake()
    {
        _instance = this;
    }

    public void ActiveRenamePanel(bool active)
    {
        RenamePanel.SetActive(active);
    }

    public void SendRenameAction()
    {
        Dictionary<byte,object> data = new Dictionary<byte, object>();
        UserDataModel model = UserInfos.CurrentUserModel;
        model.UserName = NameInput.text;
        object userdata = ProtoTranslater.GetInstance().GetBytesFromType(model);
        data.Add((byte)OperationCode.Rename, userdata);
        PhotonPeerManager.GetInstance().SendMessage(OperationCode.Rename,data);
    }
}
